(defun commonMultiples(factors)
  "returns a list of the lowest common multiples using combinations from the factors list"
  (cond ((= (length factors) 2) (list (* (car factors) (cadr factors))))
        ((> (length factors) 2) (let ((child (commonMultiples (cdr factors))))
                                  (append
                                   child
                                   (loop for f1 in (cdr factors)
                                         collect
                                         (* (car factors) f1)))))))

(defun sumMultiples (factor max)
  "this returns the sum of multiples <= the max"
  (/ (* (/ (- max (mod max factor)) factor) (+ (- max (mod max factor)) factor)) 2))

(defun TotalSumMultiplesBelow (max factors)
  "this totals the sumsofmultiples of a list of factors <= the max"
  (reduce #'+ (maplist #'(lambda (x) (sumMultiples (first x) max)) factors)))

